home *** CD-ROM | disk | FTP | other *** search
- property bx, by, binx, biny, mode, schan, findex, cnum, destx, desty, btype, animstep, direction, ancestor
-
- on birth me, snum, bugtype
- global jumpindex
- set schan to snum
- set btype to bugtype
- set cnum to the castNum of sprite schan
- set bx to the locH of sprite schan
- set by to the locV of sprite schan
- set animstep to 1
- set direction to 1
- set destx to random(290) + 200
- set desty to random(280) + 100
- puppetSprite(snum, 1)
- if btype < 7 then
- set mode to #flying
- else
- if btype < 11 then
- set mode to #crawling
- set direction to directix(bx, destx, bx, bx) / 4
- else
- set mode to #wander
- set binx to 3 * sgn(destx - bx)
- set biny to 3 * sgn(desty - by)
- set direction to directix(bx, by, destx, desty)
- end if
- end if
- return me
- end
-
- on settask me, newtask
- set mode to newtask
- end
-
- on animate me
- global blevel, semisin
- set animstep to animstep + 1
- if mode = #caught then
- set bx to the mouseH
- set by to the mouseV
- if not (the mouseDown) then
- set mode to #return
- end if
- end if
- if mode = #wander then
- if animstep > 1 then
- set animstep to 0
- end if
- set the castNum of sprite schan to cnum + (direction * 2) + animstep
- set bx to bx + binx
- set by to by + biny
- if random(30) = 1 then
- set mode to #wander2
- end if
- if (bx < 150) or (bx > 700) or (by < -50) or (by > 530) then
- set mode to #frighten
- end if
- set the castNum of sprite schan to cnum + (direction * 2) + animstep
- if random(10) = 1 then
- set direction to direction + random(3) - 2
- if direction > 7 then
- set direction to 0
- end if
- if direction < 0 then
- set direction to 7
- end if
- set binx to getPropAt(semisin, direction + 1)
- set biny to getAt(semisin, direction + 1)
- end if
- if bx < 200 then
- set direction to random(5) + 3
- if direction > 7 then
- set direction to 1
- end if
- set binx to getPropAt(semisin, direction + 1)
- set biny to getAt(semisin, direction + 1)
- end if
- end if
- if mode = #wander2 then
- if animstep > 1 then
- set animstep to 0
- end if
- set direction to direction + 1
- if direction > 7 then
- set direction to 0
- end if
- set the castNum of sprite schan to cnum + (direction * 2) + animstep
- if random(10) = 1 then
- set binx to getPropAt(semisin, direction + 1)
- set biny to getAt(semisin, direction + 1)
- set mode to #wander
- end if
- if bx < 200 then
- set direction to random(5) + 3
- if direction > 7 then
- set direction to 1
- end if
- set binx to getPropAt(semisin, direction + 1)
- set biny to getAt(semisin, direction + 1)
- end if
- end if
- if mode = #flying then
- if animstep > 2 then
- set animstep to 0
- end if
- set the castNum of sprite schan to cnum + animstep
- set bx to bx + (sgn(destx - bx) * blevel)
- set by to by + (sgn(desty - by) * blevel)
- if (abs(destx - bx) < 7) and (abs(desty - by) < 7) then
- set destx to random(290) + 200
- set desty to random(280) + 100
- if random(3) = 1 then
- set mode to #frighten
- end if
- end if
- end if
- if mode = #runaway then
- if (by < 500) and (by > 0) and (bx > 0) and (bx < 640) then
- set bx to bx + binx
- set by to by + biny
- else
- killbug(schan)
- set mode to #killhim
- end if
- end if
- if mode = #frighten then
- set binx to (-1 + ((random(2) - 1) * 3)) * 16
- set biny to (-1 + ((random(2) - 1) * 3)) * 16
- set mode to #runaway
- end if
- if mode = #crawling then
- if animstep > 2 then
- set animstep to 0
- end if
- set the castNum of sprite schan to cnum + (direction * 3) + animstep
- set bx to bx + (sgn(destx - bx) * 2)
- if abs(destx - bx) < 7 then
- set destx to 700
- set direction to directix(bx, destx, bx, bx) / 4
- set mode to #diecrawling
- end if
- end if
- if mode = #diecrawling then
- if animstep > 2 then
- set animstep to 0
- end if
- set the castNum of sprite schan to cnum + (direction * 3) + animstep
- set bx to bx + (sgn(destx - bx) * blevel * 2)
- if abs(destx - bx) < 7 then
- set mode to #killhim
- end if
- end if
- if mode = #return then
- if (bx < 0) or (bx > 640) or (by < 0) or (by > 480) then
- kill(me)
- killbug(schan)
- addbug()
- exit
- end if
- if btype < 7 then
- set mode to #flying
- else
- if btype < 11 then
- set mode to #falling
- set biny to 1
- if by < 231 then
- set desty to 231
- else
- set desty to 476
- end if
- set destx to bx
- else
- set mode to #wander
- end if
- end if
- end if
- if mode = #falling then
- if animstep > 2 then
- set animstep to 0
- end if
- set the castNum of sprite schan to cnum + (direction * 3) + animstep
- set by to by + biny
- if biny < 16 then
- set biny to biny * 2
- end if
- if by > desty then
- set by to desty
- set destx to random(740) - 50
- set direction to directix(bx, destx, bx, bx) / 4
- set mode to #crawling
- end if
- end if
- if mode = #killhim then
- set the locV of sprite schan to -200
- set by to -200
- kill(me)
- killbug(schan)
- end if
- if mode = #escaping then
- if animstep > 1 then
- set animstep to 0
- end if
- set the castNum of sprite schan to cnum
- set bx to bx + (sgn(destx - bx) * blevel * 2)
- set by to by + (sgn(desty - by) * blevel * 2)
- if by > 445 then
- set by to 446
- if abs(bx - destx) < 20 then
- set mode to #killhim
- end if
- end if
- end if
- set the locH of sprite schan to bx
- set the locV of sprite schan to by
- end
-
- on setdest me, newx, newy
- set destx to newx
- set desty to newy
- end
-
- on setbugx me, bnx
- set bx to bnx
- end
-
- on setbugxy me, bnx, bny
- set bx to bnx
- set by to bny
- end
-
- on setcastnum me, settocnum
- set cnum to settocnum
- set the castNum of sprite schan to cnum
- end
-
- on getbugtype me
- return btype
- end
-
- on kill me
- set me to 0
- end
-
- on buginfo me
- put bx, by, binx, biny, destx, desty
- put cnum, schan, findex
- end
-
- on variance me
- set temprand to random(4)
- set cnum to the number of cast string("b" & temprand)
- set mode to getAt([#bounce, #nothing, #going], temprand)
- set binx to (random(5) - 3) * 3
- set biny to (random(5) - 3) * 3
- if mode = #going then
- set destx to 50 + random(412)
- set desty to 25 + random(334)
- end if
- end
-